package com.briup.corejava.day22;

/**
 * lambda表达式的演化
 */
public class Test6 {
    public static void main(String[] args) {
        Test6 t6 = new Test6();
        t6.test(10, 20, (a,b)->a+b);
        t6.test(10, 20, (a,b)->a-b);
        Action a1 = new Action() {
            @Override
            public int calculate(int a, int b) {
                return a * b;
            }
        };
        Action a2 = (a,b) -> a/b;
        System.out.println(a1.getClass().hashCode());
        System.out.println(a2.getClass().hashCode());
    }

    public void test(int a, int b,Action action){
        // 输出计算后的结果
        System.out.println(action.calculate(a,b));
    }
}
// 计算行为
@FunctionalInterface
interface Action{
    int calculate(int a , int b);
}
